﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TntOrm.Attributes
{
    public enum BelongType { HasMany, HasOne, ManyToMany };

    [AttributeUsage( AttributeTargets.Property )]
    public class OrmReference : Attribute 
    {
        private Type _ReferenceType;

        public Type ReferenceType
        {
            get { return _ReferenceType; }
            set { _ReferenceType = value; }
        }

        private Type _ManyToManyTable;

        public Type ManyToManyTable
        {
            get { return _ManyToManyTable; }
            set { _ManyToManyTable = value; }
        }

        private string _PropertyName;

        public string CrossPropertyName
        {
            get { return _PropertyName; }
            set { _PropertyName = value; }
        }

        private string _CrossTablePropertyName;

        public string CrossTablePropertyName
        {
            get { return _CrossTablePropertyName; }
            set { _CrossTablePropertyName = value; }
        }


        private BelongType _Belonge;

        public BelongType Belonge
        {
            get { return _Belonge; }
            set { _Belonge = value; }
        }


        public OrmReference( Type ReferenceToType, string PropertyName, BelongType HowBelong )
        {
            this._ReferenceType = ReferenceToType;
            this._PropertyName = PropertyName;
            this._Belonge = HowBelong;
        }

        public OrmReference( Type ReferenceToType, string PropertyName, BelongType HowBelong, Type CrossTable, string CrossTableProperty )
        {
            this._ReferenceType = ReferenceToType;
            this._PropertyName = PropertyName;
            this._Belonge = HowBelong;
            this._ManyToManyTable = CrossTable;
            this._CrossTablePropertyName = CrossTableProperty;
        }
    }
}